package youjia;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Random
 * Package: youjia
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-09
 * Time: 17:18
 */

public class Random {
    //数组里有{1,2,3,4,5,6,7,8,9,10}，请随机打乱顺序，生成一个新的数组。
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int temp = 0;

        java.util.Random random = new java.util.Random(arr.length);

        int number = random.nextInt(arr.length);
        for (int i = 0; i < arr.length; i++) {
            temp = arr[i];
            arr[i] = arr[number];
            arr[number] = temp;
        }
        System.out.println("arr=" + Arrays.toString(arr));


    }
}
